/**
 * Created by cqmcqm on 2015/6/1.
 */

var FESW=FESW||function(){};

/**
 * 获取屏幕长宽
 */
FESW.prototype.getScreenSize=function()
{
    return {width:(document.documentElement&&document.documentElement.clientWidth)||window.innerWidth||((document.body) && (document.body.clientWidth))
        ,height:(document.documentElement&&document.documentElement.clientHeight)||window.innerHeight||((document.body) && (document.body.clientHeight))};
}

/**
 * 获取触摸事件发生的位置
 * pc端取相对位置
 * 移动端取相对屏幕位置
 */
FESW.prototype.getEventPos=function()
{
    return {x:event.offsetX||event.touches[0].clientX||0,y:event.offsetY||event.touches[0].clientY||0};
}

/**
 * 发送ajax请求
 */
FESW.prototype.sendAjaxRequest=function(requestType, url, syncFlg, postData, callback, callbackParameter)
{
    var xhr = new XMLHttpRequest();
    xhr.open(requestType, url, syncFlg);
    xhr.onreadystatechange = function () {
        if (xhr.readyState == 4 && xhr.status == 200) {
            var result = xhr.responseText;
            callback(callbackParameter,result);
        }
    }
    var form = new FormData();
    for (var i in postData) {
        form.append(i, postData[i]);
    }
    xhr.send(form);
}

